const { CronJob } = require('cron');
const Detection = require('./src/Detection');
const utils = require('./utils/utils');
const log = require('./utils/log');

// every 5 mins exec
const scheduleTask = new Detection('0 */5 * * * *');
scheduleTask.refreshData();

// every 30 mins refresh work_order data
const refreshDataCron = `30 ${utils.getExecTime()} * * * *`;
log.info('refreshDataCron is:', refreshDataCron);
const job = new CronJob(
  refreshDataCron,
  (() => {
    scheduleTask.refreshData();
  }),
);
job.start();
